﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ModelInfo {

    public string name;

    public float Px;
    public float Py;
    public float Pz;
    public float Ex;
    public float Ey;
    public float Ez;
    public bool Exists;

    public ModelInfo() {

    }

    public ModelInfo(float px, float py, float pz, float ex, float ey, float ez) : this() {
        this.Px = px;
        this.Py = py;
        this.Pz = pz;
        this.Ex = ex;
        this.Ey = ey;
        this.Ez = ez;
    }

    public ModelInfo(Transform transform) : this() {
        this.Update(transform);
    }

    public Vector3 GetPosition() {
        return new Vector3(Px, Py, Pz);
    }

    public void SetPosition(Vector3 position) {
        this.Px = position.x;
        this.Py = position.y;
        this.Pz = position.z;
    }

    public Vector3 GetEulerAngles() {
        return new Vector3(Ex, Ey, Ez);
    }

    public void SetEulerAngles(Vector3 eulerAngles) {
        this.Ex = eulerAngles.x;
        this.Ey = eulerAngles.y;
        this.Ez = eulerAngles.z;
    }

    public void UpdateTransform(Transform transform) {
        if (this.Exists) {
            transform.position = this.GetPosition();
            transform.eulerAngles = this.GetEulerAngles();
            transform.gameObject.SetActive(this.Exists);
        } else {
            transform.gameObject.SetActive(this.Exists);
        }
    }

    public void Update(Transform transform) {
        this.Update(transform.position, transform.eulerAngles);
    }

    public void Update(Vector3 position, Vector3 eulerAngles) {
        this.SetPosition(position);
        this.SetEulerAngles(eulerAngles);
    }
}
